home *** CD-ROM | disk | FTP | other *** search
/ Young & Modern Digital Makeover Magic / Young & Modern Digital Makeover Magic.iso / data1.cab / TempMKV / UtilFrameRoute.js < prev    next >
Encoding:
JavaScript  |  1999-10-18  |  7.7 KB  |  339 lines

  1. // UtilFrameRoute.js
  2. // Copyright (c) 1999 MGI Software Corp. All Rights Reserved
  3. // <Script>
  4.  
  5. ////////////////////////////////////////////////////////////////
  6. //
  7. //    Miscelaneous stuff
  8. //
  9.  
  10. function _SmartJump( fTarget, sNewTarget )
  11. {
  12.     var sFullPath;
  13.  
  14.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  15.  
  16.     return 1;
  17. }
  18.  
  19. // Absolute path version
  20. function _SmartJumpAbs( fTarget, sNewTarget )
  21. {
  22.     return 1;
  23. }
  24.  
  25. var RoutingTable = new Array;
  26.  
  27. // Remove a routing from the table
  28. function _DeleteRouting( Dest, FrameObject )
  29. {
  30.     var i;
  31.  
  32.     // Find the object to delete
  33.     for( i=0; i<RoutingTable.length; i++ )
  34.     {
  35.         // Found it
  36.         if( RoutingTable[i].Dest == Dest && RoutingTable[i].FrameObject == FrameObject )
  37.         {
  38.             // Mark as inactive
  39.             RoutingTable[i].FrameObject = null;
  40.             RoutingTable[i].Dependants = null;
  41.             
  42.             // If not already queued, disable it
  43.             if( RoutingTable[i].QueueMode == 2 )
  44.             {
  45.                 _SetQueueMode( Dest, -1, 0 );
  46.             }
  47.  
  48.             return 1;        // Success
  49.         }
  50.     }
  51.  
  52.     alert("Root.HTML, _DeleteRouting(): Routing " + Dest +" not found.");
  53.     return 0;                // Failed!
  54. }
  55.  
  56. // Add a routing to the table
  57. function _AddRouting( Dest, FrameObject, Dependants )
  58. {
  59.     var undefined;
  60.     var i;
  61.     var j;
  62.     var k;
  63.  
  64.     // Default Dependants to none
  65.     Dependants = Dependants == undefined ?"" : Dependants;
  66.  
  67.     // Make sure the routing does not already exist
  68.     for( i=0; i<RoutingTable.length; i++ )
  69.     {
  70.         if( RoutingTable[i].Dest == Dest )
  71.         {
  72.             // Enabled?
  73.             if( RoutingTable[i].FrameObject != null )
  74.             {
  75.                 alert("Root.html, AddRouting(): Rooting " + Dest +" already exists.");
  76.                 return 0;        // Failed!
  77.             }
  78.         
  79.             // Modify
  80.             RoutingTable[i].FrameObject = FrameObject;
  81.             RoutingTable[i].Dependants = new Array;
  82.  
  83.             // Parse the dependants
  84.             j=0;
  85.             k=Dependants.indexOf(",", 0);
  86.             while( k >= 0 )
  87.             {
  88.                 // Store
  89.                 RoutingTable[i].Dependants[RoutingTable[i].Dependants.length++] = 
  90.                     Dependants.substr(j, k-j);
  91.                 
  92.                 j = k+1;        // 1 is ",".length
  93.                 k=Dependants.indexOf(",", j);
  94.             }
  95.             if( j < Dependants.length )        // Last one not followed by comma
  96.             {
  97.                 RoutingTable[i].Dependants[RoutingTable[i].Dependants.length++] = 
  98.                     Dependants.substr(j);
  99.             }
  100.                             
  101.             _SetQueueMode( Dest, 2 );
  102.             return 1;            // Success
  103.         }
  104.     }
  105.  
  106.     RoutingTable.length += 1;
  107.     RoutingTable[i] = new Object;
  108.  
  109.     RoutingTable[i].Dest = Dest;
  110.     RoutingTable[i].FrameObject = FrameObject;
  111.     RoutingTable[i].QueueMode = 2;
  112.     RoutingTable[i].CallQueue ="";
  113.  
  114.     RoutingTable[i].Dependants = new Array;
  115.  
  116.     // Parse the dependants
  117.     j=0;
  118.     k=Dependants.indexOf(",", 0);
  119.     while( k >= 0 )
  120.     {
  121.         // Store
  122.         RoutingTable[i].Dependants[RoutingTable[i].Dependants.length++] = 
  123.             Dependants.substr(j, k-j);
  124.         
  125.         j = k+1;        // 1 is ",".length
  126.         k=Dependants.indexOf(",", j);
  127.     }
  128.     if( j < Dependants.length )        // Last one not followed by comma
  129.     {
  130.         RoutingTable[i].Dependants[RoutingTable[i].Dependants.length++] = 
  131.             Dependants.substr(j);
  132.     }
  133.  
  134.     return 1;                // Success
  135. }
  136.  
  137. // Route a call to the proper destination
  138. function _RouteCall( Dest, strEvalCode )
  139. {
  140.     var i;
  141.     // Dest is a Div
  142.  
  143.     // Find the destination
  144.     for( i=0; i<RoutingTable.length; i++ )
  145.     {
  146.         if( RoutingTable[i].Dest == Dest )
  147.         {
  148.             switch( RoutingTable[i].QueueMode ) {
  149.             case -1:        // Disabled
  150.                 return -1;
  151.             case 0:            // Queue
  152.             case 1:
  153.                 RoutingTable[i].CallQueue = RoutingTable[i].CallQueue.concat(strEvalCode);
  154.                 return 0;
  155.             case 2:            // Normal
  156.                 if( RoutingTable[i].FrameObject == null )
  157.                 {
  158.                     // Target is inactive
  159.                     break;
  160.                 }
  161. top.debugalert("RouteCall("+strEvalCode+")");
  162.                 return RoutingTable[i].FrameObject.EvalCode( strEvalCode );
  163.                 //return window.frames["Liquid"].EvalCode( strEvalCode );
  164.                 //return EvalCode( strEvalCode );
  165.             }
  166.         }
  167.     }
  168.  
  169.     alert("Root.html, _RouteCall(): Routing " + Dest +" not found." );
  170.  
  171.     return 0;                // Failed (routing not found)
  172. }
  173.  
  174. // Set Queue mode
  175. // Mode = 2: Normal (setting this executes the queue);
  176. // Mode = 1: Indirectly queued (through dependancies)
  177. // Mode = 0: Queue calls;
  178. // Mode =-1: Ignore calls;
  179. function _SetQueueMode( Dest, Mode, Recurse )
  180. {
  181.     var undefined;
  182.     var i;
  183.     var j;
  184.  
  185.     // Default Recurse to False
  186.     Recurse = Recurse == undefined ? false : Recurse;
  187.  
  188.     // Insure Mode is in range
  189.     if( Mode < -1 || Mode > 2 )
  190.     {
  191.         alert("root.html, _SetQueueMode(): Mode out of range.");
  192.         return 0;
  193.     }
  194.  
  195.     // Find the routing to set
  196.     for( i=0; i<RoutingTable.length; i++ )
  197.     {
  198.         // Found it
  199.         if( RoutingTable[i].Dest == Dest )
  200.         {
  201.             // Setting normal mode, execute the queue
  202.             if( Mode == 2 && RoutingTable[i].FrameObject != null )
  203.             {
  204.                 RoutingTable[i].QueueMode = Mode;
  205.                 j = RoutingTable[i].FrameObject.EvalCode( RoutingTable[i].CallQueue );
  206.                 //j = EvalCode( RoutingTable[i].CallQueue );
  207.  
  208.                 RoutingTable[i].CallQueue ="";
  209.                 return j;
  210.             }
  211.  
  212.             // Clear the queue for explicit queuing and disabling, unless implicit queuing
  213.             // has already been set
  214.             if( (Mode == -1) ||
  215.                 (Mode == 0 && RoutingTable[i].QueueMode == 0) ||
  216.                 (Mode == 1 && RoutingTable[i].QueueMode == 0) ||
  217.                 (Mode == 1 && RoutingTable[i].QueueMode == 1) )
  218.             {
  219.                 RoutingTable[i].CallQueue ="";
  220.             }
  221.  
  222.             RoutingTable[i].QueueMode = Mode;
  223.  
  224.             // Recurse dependants
  225.             if( Recurse && RoutingTable[i].Dependants != null )
  226.             {
  227.                 for( j=0; j<RoutingTable[i].Dependants.length; j++ )
  228.                 {
  229.                     _SetQueueMode( RoutingTable[i].Dependants[j], (Mode==0 ? 1 : Mode), 1 );
  230.                 }
  231.             }
  232.  
  233.             return 1;            // Return normally
  234.         }
  235.     }
  236.  
  237.     // Does not exist? Create it to null
  238.     _AddRouting( Dest, null );
  239.  
  240.     // Try again!
  241.     _SetQueueMode( Dest, Mode, Recurse );
  242.  
  243.     return 0;
  244. }
  245.  
  246. ///////////////////////////////////////////////////////////////////////////////
  247. //
  248. // Routed calls 
  249. //
  250.  
  251. function _RPASetTarget(NewTarget)
  252. {
  253.     //if( SmartJumpAbs( window.frames["RightPaneA"], NewTarget ) )
  254.     //{
  255.         _SetQueueMode( "RightPaneA", 0, 1 );
  256.     //}
  257. }
  258.  
  259. function _TKSetTarget(NewTarget)
  260. {
  261.     //if( SmartJumpAbs( window.frames["ActivityList"], NewTarget ) )
  262.     //{
  263.         _SetQueueMode( "ActivityList", 0, 1 );
  264.     //}
  265. }
  266.  
  267.  
  268. function _TSetTarget(NewTarget)
  269. {
  270.     //if( SmartJumpAbs( window.frames["Tools"], NewTarget ) )
  271.     {
  272.         SetQueueMode( "Tools", 0, 1 );
  273.     }
  274. }
  275.  
  276. function _WSetTarget( NewTarget )
  277. {
  278.     //if( SmartJumpAbs( window.frames["WorkArea"], NewTarget ) )
  279.     {
  280.         SetQueueMode("WorkArea", 0, 1);
  281.     }
  282. }
  283.  
  284. function _BTSetTarget(NewTarget)
  285. {
  286.     //if( SmartJumpAbs( window.frames["BuddyTools"], NewTarget ) )
  287.     {
  288.         SetQueueMode("BuddyTools", 0, 1);
  289.     }
  290. }
  291.  
  292. function _GetLanguageFolder()
  293. {
  294.     return "English";
  295. }
  296.  
  297.  
  298.  
  299. ///////////////////////////////////////////////////////////////////////////////
  300. //
  301. // Set up
  302. //
  303.  
  304.  
  305.  
  306. // Register all global targets to null before anyone else and queue them
  307. function AddAllRouting()
  308. {
  309.     _AddRouting("Liquid", null);
  310.     _SetQueueMode("Liquid", 1 );
  311. //    _AddRouting("ActivityList", null);
  312. //    _SetQueueMode("ActivityList", 1 );
  313. //    _AddRouting("Menu", null);
  314. //    _SetQueueMode("Menu", 1 );
  315. //    _AddRouting("Browser", null);
  316. //    _SetQueueMode("Browser", 1 );
  317. //    _AddRouting("Tools", null);
  318. //    _SetQueueMode("Tools", 1 );
  319. //    _AddRouting("ToolKits", null);
  320. //    _SetQueueMode("ToolKits", 1 );
  321. //    _AddRouting("CommandBar", null);
  322. //    _SetQueueMode("CommandBar", 1 );
  323. //    _AddRouting("ShelfBar", null);
  324. //    _SetQueueMode("ShelfBar", 1 );
  325. //    _AddRouting("WorkArea", null);
  326. //    _SetQueueMode("WorkArea", 1 );
  327. //    _AddRouting("Shelves", null);
  328. //    _SetQueueMode("Shelves", 1 );
  329. //    _AddRouting("BuddyTools", null);
  330. //    _SetQueueMode("BuddyTools", 1 );
  331. //    _AddRouting("P_Tools", null);
  332. //    _SetQueueMode("P_Tools", 1 );
  333. //    _AddRouting("P_WorkArea", null);
  334. //    _SetQueueMode("P_WorkArea", 1 );
  335. //    _AddRouting("P_BuddyTools", null);
  336. //    _SetQueueMode("P_BuddyTools", 1 );
  337.  
  338. }
  339.